package chapter06

/**
 *
 * @author cdhuangchao3
 * @date 2023/6/9 8:15 PM
 */
object Test16_TraitSelfType {
  def main(args: Array[String]): Unit = {
    val user = new RegisterUser("zs", "abc")
    user.insert()
  }
}

// 用户
class User(val name: String, val password: String)

trait UserDao {
//  _: User =>
  this: User =>
  def insert(): Unit = {
    println(s"insert into db: ${name}")
  }
}
// 注册用户类
class RegisterUser(name: String, password: String) extends User(name, password) with UserDao